<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:ry="">
	<head>
		<th:block th:include="include :: header('修改定时任务')" />
	</head>
	<body class="white-bg">
		<div class="wrapper wrapper-content animated fadeInRight ibox-content">
			<form class="form-horizontal m" id="form-job-edit">
				<input id="job_id" name="job_id" type="hidden" th:value="${job.jobId}"/>
				<div class="form-group">
					<label class="col-sm-3 control-label is-required">任务名称：</label>
					<div class="col-sm-8">
						<input class="form-control" type="text" name="job_name" id="job_name" th:value="${job.jobName}" required/>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-3 control-label">任务分组：</label>
					<div class="col-sm-8">
						<ry:selectDict dictType="sys_job_group" name="job_group" class="form-control m-b" th:value="${job.jobGroup}"/>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-3 control-label is-required">调用目标字符串：</label>
					<div class="col-sm-8">
						<input class="form-control" type="text" name="invoke_target" id="invoke_target" th:value="${job.invokeTarget}" required/>
					    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> Bean调用示例：ryTask.ryParams('ry')</span>
					    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> Class类调用示例：com.ruoyi.quartz.task.RyTask.ryParams('ry')</span>
					    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 参数说明：支持字符串，布尔类型，长整型，浮点型，整型</span>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-3 control-label is-required">cron表达式：</label>
					<div class="col-sm-8">
						<input class="form-control" type="text" name="cron_expression" id="cron_expression" th:value="${job.cronExpression}" required/>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-3 control-label">执行策略：</label>
					<div class="col-sm-8">
						<label class="radio-box"> <input type="radio" name="misfire_policy" value="1" th:checked="${job.misfirePolicy == '1'}"/> 立即执行 </label>
						<label class="radio-box"> <input type="radio" name="misfire_policy" value="2" th:checked="${job.misfirePolicy == '2'}"/> 执行一次 </label>
						<label class="radio-box"> <input type="radio" name="misfire_policy" value="3" th:checked="${job.misfirePolicy == '3'}"/> 放弃执行 </label>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-3 control-label">并发执行：</label>
					<div class="col-sm-8">
						<label class="radio-box"> <input type="radio" th:field="${job.concurrent}" name="concurrent" value="0"/> 允许 </label>
						<label class="radio-box"> <input type="radio" th:field="${job.concurrent}" name="concurrent" value="1"/> 禁止 </label>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-3 control-label">状态：</label>
					<div class="col-sm-8">
						<ry:radioDict dictType="sys_job_status" name="status" class="radio-box" required="true" th:value="${job.status}"/>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-3 control-label">备注：</label>
					<div class="col-sm-8">
						<textarea id="remark" name="remark" class="form-control">[[${job.remark}]]</textarea>
					</div>
				</div>
			</form>
		</div>
		<th:block th:include="include :: footer" />
		<script type="text/javascript">
			var prefix = ctx + "monitor/job";

			$("#form-job-edit").validate({
				onkeyup: false,
				rules:{
					cron_expression:{
						required:true,
						remote: {
		                    url: prefix + "/checkCronExpressionIsValid",
		                    type: "post",
		                    dataType: "json",
		                    data: {
		                        "cron_expression": function() {
		                            return $.common.trim($("#cron_expression").val());
		                        }
		                    },
		                    dataFilter: function(data, type) {
		                    	return data;
		                    }
		                }
					},
				},
				messages: {
		            "cron_expression": {
		                remote: "表达式不正确"
		            }
		        },
		        focusCleanup: true
			});

			function submitHandler() {
		        if ($.validate.form()) {
		        	$.operate.save(prefix + "/edit", $('#form-job-edit').serialize());
		        }
		    }
		</script>
	</body>
</html>